package org.jcnc.staffingsystem.stage;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import org.jcnc.staffingsystem.list.Employee;

public class EmployeeTrainingArrangementsBox extends VBox {
    TableView<Employee> tableView;
    TableColumn<Employee, String> name;
    TableColumn<Employee, String> employeeNumber;
    TableColumn<Employee, String> chosenClasses;
    TableColumn<Employee, String> assessmentResults;

    public EmployeeTrainingArrangementsBox() {
        tableView = new TableView<>();

        name = new TableColumn<>("姓名");
        employeeNumber = new TableColumn<>("工号");
        chosenClasses = new TableColumn<>("已选课程");
        assessmentResults = new TableColumn<>("考核成绩");

        name.setCellValueFactory(new PropertyValueFactory<Employee, String>("name"));
        employeeNumber.setCellValueFactory(new PropertyValueFactory<Employee, String>("employeeNumber"));
        chosenClasses.setCellValueFactory(new PropertyValueFactory<Employee, String>("chosenClasses"));
        assessmentResults.setCellValueFactory(new PropertyValueFactory<Employee, String>("assessmentResults"));

        name.setPrefWidth(100);
        employeeNumber.setPrefWidth(100);
        chosenClasses.setPrefWidth(300);
        assessmentResults.setPrefWidth(300);

        tableView.getColumns().addAll(name, employeeNumber, chosenClasses, assessmentResults);
        tableView.setPrefSize(30000, 300000);
        tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
        ObservableList<Employee> data = FXCollections.observableArrayList();

        System.out.println(111);
        data.add(new Employee("张三", "001", "Java 编程", "优秀"));
        tableView.setItems(data);

        this.getChildren().addAll(tableView);
        this.setPadding(new Insets(20));
    }
}